<html>
<head>
    <title></title>
    <meta charset='utf-8'>
    <script src="../js/lib/jquery.js"></script>
</head>
<body>


<p>test post json</p>
<button id="testPostJson"> testPostJson</button>

<hr/>
<p>test post form</p>

<form action="/test/form" method="post">
    <input type="text" name="foo"><br>
    <input type="submit" value="submit">
</form>

<hr/>
<p>test post multipart</p>

<form action="/test/multipart" enctype="multipart/form-data" method="post">
    <input type="text" name="title"><br>
    <input type="file" name="upload" multiple="multiple"><br>
    <input type="submit" value="Upload">
</form>

<script type="text/javascript">

    function testPostJson() {
        var up = {
            a: "hello"
        };
        console.log('upload:', JSON.stringify(up));
        $.ajax({
            url: "/test/json",
            type: "POST",
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(up),
            success: function (res) {
                console.log('succ', res);
            },
            error: function (res) {
                console.log('error', res);
            }
        });
    }

    $(document).ready(function () {
        $('#testPostJson').on('click', testPostJson);
    });
</script>
</body>
</html>